'\" e
'\"! eqn | mmdoc
'\"macro stdmacro
.ds Vn Version 1.2
.ds Dt 24 September 1999
.ds Re Release 1.2.1
.ds Dp Jan 14 18:30
.ds Dm 01 frustum.g
.ds Xs 13962 6 frustum.gl
.TH GLFRUSTUM 3G
.SH NAME
.B "glFrustum
\- multiply the current matrix by a perspective matrix

.SH C SPECIFICATION
void \f3glFrustum\fP(
GLdouble \fIleft\fP,
.nf
.ta \w'\f3void \fPglFrustum( 'u
	GLdouble \fIright\fP,
	GLdouble \fIbottom\fP,
	GLdouble \fItop\fP,
	GLdouble \fInear_val\fP,
	GLdouble \fIfar_val\fP )
.fi

.EQ
delim $$
.EN
.SH PARAMETERS
.TP \w'\f2left\fP\ \f2right\fP\ \ 'u 
\f2left\fP, \f2right\fP
Specify the coordinates for the left and right vertical clipping planes.
.TP
\f2bottom\fP, \f2top\fP
Specify the coordinates for the bottom and top horizontal clipping planes.
.TP
\f2near_val\fP, \f2far_val\fP
Specify the distances to the near and far depth clipping planes.
Both distances must be positive.
.SH DESCRIPTION
\%\f3glFrustum\fP describes a perspective matrix that produces a perspective projection.
The current matrix (see \%\f3glMatrixMode\fP) is multiplied by this matrix
and the result replaces the current matrix, as if
\%\f3glMultMatrix\fP were called with the following matrix
as its argument:
.P
.sp 5
.ce
.EQ
down 150
{left [ ~~~ { 
down 165 matrix {
   ccol { {{2 ~ "near_val"} over {"right" ~-~ "left"}} above 0 above 0 above 0 }
   ccol { 0 above {{2 ~ "near_val"} over {"top" ~-~ "bottom"}} ~ above 0 above 0 }
   ccol { A ~~~~ above B ~~~~ above C ~~~~ above -1 ~~~~}
   ccol { 0 above 0 above D above 0}
}}
~~~ right ]}
.EN
.sp
.ce
.EQ
down 130
{A ~=~ {"right" ~+~ "left"} over {"right" ~-~ "left"}}
.EN
.sp
.ce
.EQ
down 130
{B ~=~ {"top" ~+~ "bottom"} over {"top" ~-~ "bottom"}}
.EN
.sp
.ce
.EQ
down 130
{C ~=~ -{{"far_val" ~+~ "near_val"} over {"far_val" ~-~ "near_val"}}}
.EN
.sp
.ce
.EQ
down 130
{D ~=~ -^{{2 ~ "far_val" ~ "near_val"} over {"far_val" ~-~ "near_val"}}}
.EN
.sp 2
.P
Typically, the matrix mode is \%\f3GL_PROJECTION\fP, and
(\f2left\fP, \f2bottom\fP, \-\f2near_val\fP) and (\f2right\fP, \f2top\fP,  \-\f2near_val\fP)
specify the points on the near clipping plane that are mapped
to the lower left and upper right corners of the window,
assuming that the eye is located at (0, 0, 0).
\-\f2far_val\fP specifies the location of the far clipping plane.
Both \f2near_val\fP and \f2far_val\fP must be positive.
.P
Use \%\f3glPushMatrix\fP and \%\f3glPopMatrix\fP to save and restore
the current matrix stack.
.SH NOTES
Depth buffer precision is affected by the values specified for
\f2near_val\fP and \f2far_val\fP.
The greater the ratio of \f2far_val\fP to \f2near_val\fP is,
the less effective the depth buffer will be at distinguishing between
surfaces that are near each other.
If 
.sp
.ce
$r ~=~ "far_val" over "near_val"$
.sp
roughly $log sub 2 (r)$ bits of depth buffer precision are lost.
Because $r$ approaches infinity as \f2near_val\fP approaches 0,
\f2near_val\fP must never be set to 0.
.SH ERRORS
\%\f3GL_INVALID_VALUE\fP is generated if \f2near_val\fP or \f2far_val\fP is not
positive, or if \f2left\fP = \f2right\fP, or \f2bottom\fP = \f2top\fP.
.P
\%\f3GL_INVALID_OPERATION\fP is generated if \%\f3glFrustum\fP
is executed between the execution of \%\f3glBegin\fP
and the corresponding execution of \%\f3glEnd\fP.
.SH ASSOCIATED GETS
\%\f3glGet\fP with argument \%\f3GL_MATRIX_MODE\fP
.br
\%\f3glGet\fP with argument \%\f3GL_MODELVIEW_MATRIX\fP
.br
\%\f3glGet\fP with argument \%\f3GL_PROJECTION_MATRIX\fP
.br
\%\f3glGet\fP with argument \%\f3GL_TEXTURE_MATRIX\fP
.br
\%\f3glGet\fP with argument \%\f3GL_COLOR_MATRIX\fP
.SH SEE ALSO
\%\f3glOrtho(3G)\fP,
\%\f3glMatrixMode(3G)\fP,
\%\f3glMultMatrix(3G)\fP, 
\%\f3glPushMatrix(3G)\fP,
\%\f3glViewport(3G)\fP
